package com.Jeu;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;

public class ImageAdapter extends BaseAdapter {
	private Context mContext;

	public ImageAdapter(Context c) {
		mContext = c;
	}

	public int getCount() {
		return mThumbIds.length;
	}

	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return mThumbIds[position];
	}

	// create a new ImageView for each item referenced by the Adapter
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView == null) { // if it's not recycled, initialize some
			// attributes
			imageView = new ImageView(mContext);
			imageView.setLayoutParams(new GridView.LayoutParams(75, 75));
			imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
			imageView.setPadding(8, 8, 8, 8);
		} else {
			imageView = (ImageView) convertView;
		}
		imageView.setImageResource(mThumbIds[position]);
		return imageView;
		// // return b;
		// return btn;
		// Button btn;
		// if (convertView == null) {
		// // if it's not recycled, initialize some attributes
		// btn = new Button(mContext);
		// btn.setLayoutParams(new GridView.LayoutParams(75, 75));
		// btn.setPadding(8, 8, 8, 8);
		// } else {
		// btn = (Button) convertView;
		// }
		// exus
		// btn.setText("Van xinh");
		// filenames is an array of strings
		// btn.setTextColor(Color.WHITE);
		// btn.setBackgroundResource(R.drawable.carton);
		// btn.setId(position);
		// btn.setOnClickListener(new OnClickListener() {
		// @Override
		// public void onClick(View v) {
		//
		// }
		// });
		//
		// return btn;
	}

	// references to our images
	private Integer[] mThumbIds = { R.drawable.carton, R.drawable.carton,
			R.drawable.carton, R.drawable.carton, R.drawable.carton,
			R.drawable.carton, R.drawable.carton, R.drawable.carton,
			R.drawable.carton, R.drawable.carton, R.drawable.carton,
			R.drawable.carton, R.drawable.carton, R.drawable.carton,
			R.drawable.carton, R.drawable.carton };
	private Integer[] test = { R.drawable.spa1_button, R.drawable.spa1_button,
			R.drawable.spa1_button, R.drawable.spa1_button,
			R.drawable.spa1_button, R.drawable.spa1_button,
			R.drawable.spa1_button, R.drawable.spa1_button,
			R.drawable.spa1_button, R.drawable.spa1_button,
			R.drawable.spa1_button, R.drawable.spa1_button,
			R.drawable.spa1_button, R.drawable.spa1_button,
			R.drawable.spa1_button, R.drawable.spa1_button };
}
